"""
@author: Sergiy Tsymbalyuk
"""

from chowa.lib import components

import pkgutil


class PanelComponent(type):
    pass


def get_components():
    component_list = {}
    modules = [module for _, module, _ in pkgutil.iter_modules(components.__path__)]
    __import__(components.__name__, fromlist=modules)
    for module_name in modules:
        try:
            module = components.__dict__[module_name]
            vars = module.__dict__
            for var_name in vars:
                if type(vars[var_name]) == PanelComponent:
                    component_list['.'.join((components.__name__, module_name, var_name))] = '%s :: %s' % (module_name, var_name)
        except Exception, e:
            print e
    return component_list
